<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
author : chain
create date : 19/01/2556
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:totoland="http://java.sun.com/jsf/composite/components">
    <h:head></h:head>
    <h:body>
        <ui:composition template="/template/etcTemplateGreen.xhtml">
            <ui:define name="content">
                <style>
                    div[id="formUser:growlRight_container"] {
                        position:absolute;
                        top:20px;
                    }
                    div[id="formUser:msgs_container"] {
                        position:absolute;
                        top:20px;
                        left:40%;
                    }
                </style>
                
                <h:form id="formUser">                    
                    <p:growl id="msgs"/>

                    <p:panel header="ค้นหาข้อมูลนักศึกษา" style="margin-top: 20px">
                        <h:panelGrid columns="3">
                            <h:outputText value="รหัสนักศึกษา (10 หลัก)"/>
                            <p:inputMask mask="9999999999" value="#{captureInfoController.searching}" size="30" maxlength="100" required="true" requiredMessage="กรุณาระบุรหัสนักศึกษา"/>
                            <p:commandButton value="ค้นหา" action="#{captureInfoController.searchInfo()}" update="formUser"/>
                        </h:panelGrid>
                    </p:panel>
                    
                    <p:panel header="ข้อมูลนักศึกษา" rendered="#{captureInfoController.allowCapture}" id="pnStudentInfo">
                        <h:panelGrid columns="4">
                            <h:outputText value="#{captureInfoController.studentInfo.prefix}" rendered="#{!captureInfoController.editMode}"/>
                            <p:inputText value="#{captureInfoController.studentInfo.prefix}" size="10" maxlength="255" rendered="#{captureInfoController.editMode}"/>
                            <h:outputText value="#{captureInfoController.studentInfo.FName}" rendered="#{!captureInfoController.editMode}"/>
                            <p:inputText value="#{captureInfoController.studentInfo.FName}" size="30" maxlength="255" rendered="#{captureInfoController.editMode}"/>
                            
                            <h:outputText value="นามสกุล"/>
                            <h:outputText value="#{captureInfoController.studentInfo.LName}" rendered="#{!captureInfoController.editMode}"/>
                            <p:inputText value="#{captureInfoController.studentInfo.LName}" size="30" maxlength="255" rendered="#{captureInfoController.editMode}"/>
                            
                            <h:outputText value="Class"/>
                            <h:outputText value="#{captureInfoController.studentInfo.className}"/>
                            <h:outputText value="คณะ"/>
                            <h:outputText value="#{captureInfoController.studentInfo.facultyName}"/>
                            
                            <h:outputText value="สาขา"/>
                            <h:outputText value="#{captureInfoController.studentInfo.majorName}"/>
                            <h:outputText value="วันหมดอายุบัตร"/>
                            <h:outputText value="#{captureInfoController.studentInfo.exp}">
                                <f:convertDateTime locale="th-TH"/>
                            </h:outputText>
                            
                            <p:commandButton action="#{captureInfoController.goToEdit()}" value="แก้ใข" process="pnStudentInfo" update="pnStudentInfo" rendered="#{!captureInfoController.editMode}"></p:commandButton>
                            <p:commandButton action="#{captureInfoController.updateInfo()}" value="บันทึก" process="pnStudentInfo" update="formUser" rendered="#{captureInfoController.editMode}"></p:commandButton>
                            <p:commandButton action="#{captureInfoController.goToCancel()}" value="ยกเลิก" process="pnStudentInfo" update="pnStudentInfo" rendered="#{captureInfoController.editMode}"></p:commandButton>
                        </h:panelGrid>
                    </p:panel>

                    <p:panel header="ถ่ายภาพ" id="gridCapture" rendered="#{captureInfoController.allowCapture}">
                        <h:panelGrid columns="5" cellpadding="5">
                            <p:photoCam widgetVar="pc" listener="#{captureInfoController.oncapture}" update="formUser"/>
                            <p:commandButton type="button" value="ถ่ายรูป" onclick="blogui.show();PF('pc').capture()" onstart="blogui.show()"/>
                            <p:imageCropper id="photo" value="#{captureInfoController.croppedImage}" 
                                            image="#{captureInfoController.filename}" rendered="#{captureInfoController.allowCrop}"
                                            maxSize="#{captureInfoController.maxSize}" minSize="#{captureInfoController.minSize}" 
                                            initialCoords="#{captureInfoController.initialCoords}"/>

                            <p:commandButton id="btCrop" value="ตัด" action="#{captureInfoController.crop}" rendered="#{captureInfoController.allowCrop}" update="formUser" icon="ui-icon-scissors"/>
                            <p:graphicImage id="cropped" url="#{captureInfoController.newImageName}" height="211" rendered="#{captureInfoController.allowCombine}" onclick="window.open(this.src)" style="cursor: pointer" alt="กดเพื่อแสดงภาพตัวอย่าง"/>
                            <p:graphicImage id="combindWithOutBG" value="#{captureInfoController.combindWithOutBG}" height="307" rendered="#{captureInfoController.combindWithOutBG!=null}" style="display: none"/>
                        </h:panelGrid>
                    </p:panel>
                    
                    <p:panel rendered="#{captureInfoController.croppedImage!=null}">
                        <h:panelGrid columns="3" cellpadding="5">
                            <p:commandButton value="พิมพ์บัตร" type="button" icon="ui-icon-print" style="display:block;" onclick="PrimeFaces.Expressions.resolveComponentsAsSelector('formUser:combindWithOutBG').show();" onblur="PrimeFaces.Expressions.resolveComponentsAsSelector('formUser:combindWithOutBG').hide()">
                                <p:printer target="formUser:combindWithOutBG" />
                            </p:commandButton>
                            <p:commandButton value="ส่งข้อมูลพร้อมภาพ" icon="ui-icon-disk" action="#{captureInfoController.save()}" update="formUser" onclick="return confirm('ยืนยันการส่งข้อมูล')"></p:commandButton>
                        </h:panelGrid>
                    </p:panel>
                    <p:panel rendered="#{captureInfoController.allowCapture}">
                        <p:commandButton value="ส่งข้อมูล" icon="ui-icon-disk" action="#{captureInfoController.saveWithOutCapture()}" update="formUser" onclick="return confirm('ยืนยันการส่งข้อมูล')"></p:commandButton>
                    </p:panel>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>